/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.application.Platform
 *  javafx.event.ActionEvent
 *  javafx.event.EventHandler
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.layout.Pane
 *  javafx.stage.Modality
 *  javafx.stage.Stage
 *  javafx.stage.WindowEvent
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.salesReceipts;

import cn.hutool.core.util.ObjectUtil;
import com.gys.common.util.CacheUtil;
import com.gys.common.util.CommonUtil;
import com.gys.common.util.SpringUtil;
import com.gys.controller.BaseController;
import com.gys.controller.dataManger.ControllerManger;
import com.gys.controller.salesReceipts.ChangeDutyTipController;
import com.gys.controller.salesReceipts.SalesReceiptsMainController;
import com.gys.view.salesReceipts.ChangeDutyTipView;
import com.gys.view.salesReceipts.ChangeDutyView;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.Pane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class ChangeDutyController
extends BaseController
implements Initializable {
    @FXML
    private Pane changeDutyPane;
    @Autowired
    private SalesReceiptsMainController salesReceiptsMainController;
    @Autowired
    private ChangeDutyTipController changeDutyTipController;

    public void initialize(URL location, ResourceBundle resources) {
        ControllerManger.controllerMap.put(this.getClass().getSimpleName(), this);
        new Timer().schedule(new TimerTask(){

            @Override
            public void run() {
                ChangeDutyView view = SpringUtil.getBean(ChangeDutyView.class);
                Stage stage = (Stage)view.getView().getScene().getWindow();
                stage.setOnCloseRequest((EventHandler)new EventHandler<WindowEvent>(){

                    public void handle(WindowEvent event) {
                        CacheUtil.put("isChangeDutyCurrentView", false);
                    }
                });
            }
        }, 1000L);
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.changeDutyPane)) {
            return;
        }
        CacheUtil.put("isChangeDutyCurrentView", true);
    }

    @FXML
    private void changeAction(ActionEvent event) {
        this.closeAction();
        this.changeDutyTipController.init();
        Platform.runLater((Runnable)new Runnable(){

            @Override
            public void run() {
                CommonUtil.showView(ChangeDutyTipView.class, Modality.APPLICATION_MODAL);
            }
        });
    }

    @FXML
    private void laterAction(ActionEvent event) {
        this.closeAction();
        CacheUtil.put("needChange", 1);
        this.salesReceiptsMainController.changDutyTip();
        this.salesReceiptsMainController.getInputTextField().requestFocus();
    }

    private void closeAction() {
        CacheUtil.put("isChangeDutyCurrentView", false);
        this.changeDutyPane.getScene().getWindow().hide();
    }
}

